<%@ page import="xyz.vmcserver.wdibbs.model.vo.User" %><%--
  Created by IntelliJ IDEA.
  User: 11382
  Date: 2022/5/15
  Time: 8:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String alias = "点击登录";
    String header_url = "notLogin.jpg";
    int uid = -1;
    int permission = 0;
    User isLoginUser;
    if(null==session.getAttribute("isLoginUser")){
        if(null!=request.getAttribute("respondUser")){
            session.setAttribute("isLoginUser",request.getAttribute("respondUser"));
            session.setAttribute("permission",request.getAttribute("userPermissions"));
        }
    }
    if(null!=session.getAttribute("isLoginUser")){
        isLoginUser = (User)session.getAttribute("isLoginUser");
        uid = isLoginUser.getId();
        permission = (Integer) session.getAttribute("permission");
        alias = isLoginUser.getAlias();
        header_url = isLoginUser.getHeader_url();
    }
%>
<style>
    #searchButton{
        font-size: 15px;
        width: 70px;
    }
    .dropdown-menu{
        background: rgba(11, 94, 215, 0.75);
        min-width: 50px;
    }
    .nav-item{
        border-left:2px solid rgba(45, 199, 77, 0.76);
        border-bottom-left-radius:0.9em;
        /*border-left-width: 10px;*/
    }
    .container-fluid{
        background-color: rgba(49, 125, 255, 0.51);
        border: 0 solid rgba(11, 94, 215, 0.75);
        border-radius: 0.9em;
        position: fixed;
        top: 0;
        z-index: 999;
    }
    .navbar{
        padding-top: 0;

    }
    .container{
        padding-top: 65px;
    }
    .d-flex{
        padding-top: 12px;
    }
    li{
        list-style-type:none;
    }
    #userinfo{
        padding:0;
        margin:0;
    }
    #userinfo>.nav-item{
        border-left:0 ;
    }
</style>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container-fluid">
        <a class="navbar-brand" href="https://www.tdft.xyz">
            <img src="/static/img/logoti.png" alt="" width="140px" height="48px">BBS
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="${pageContext.request.contextPath}/home">主页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <img src="/static/img/hot.png" alt="" width="20px" height="20px">近期热点
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        公告版
                    </a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        帖子分区
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/allZone">全部分区</a></li>
                        <li><a class="dropdown-item" href="#">闲谈交流</a></li>
                        <li><a class="dropdown-item" href="#">失物招领</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="#">编程竞赛</a></li>
                    </ul>
                </li>
                <li class="nav-item">
                    <a class="nav-link disabled">微梦岛BBS•微小却从不天真的梦</a>
                </li>
            </ul>
            <div class="d-flex" role="search">
                <input class="form-control me-2" type="search" id="searchValue" placeholder="快来发现有趣的帖子吧~" aria-label="Search">
                <button class="btn btn-outline-success" id="searchButton">搜索</button>
            </div>
            <ul id="userinfo">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="1navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        <img width="35px" height=35px src="/userHeader/<%=header_url%>" class="rounded-circle">
                        <%=alias%>
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown" id="userop">
                        <% if(-1!=uid){
                            if(150<=permission){
                        %>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/admin/home">管理主页</a></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/admin/mail">发送邮件</a></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/admin/userManager">用户管理</a></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/groupInfo">用户组管理</a></li>
                        <%}%>

                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/${isLoginUser.username}">个人信息</a></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/logout">注销登录</a></li>
                        <%}else{%>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/login">跳转登录</a></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/register">前往注册</a></li>
                        <%}%>
                    </ul>
                </li>
            </ul>


        </div>
    </div>
</nav>
<script>
    $(function (){
        $("#searchButton").click(function (){
            let sv = $("#searchValue").val()
            window.location.href ="${pageContext.request.contextPath}/sa?wd="+sv;
            // alert("search")
        });
    });
</script>